const http = require('node:http')
//data:text/html;utf8,<p>abc</p>
//stream  流   读 read 写 write end
//事件  data
//
//任务 node写一个client 代替浏览器 让server正常返回工作
const server = http.createServer((req, res) => {
  console.log({ req })
  // fs.createReadStream(__dirname+'/node.md').pipe(res)
  res.write("<h1> hello world</h1>")
  res.end()
})

server.on("clientError", (err, socket) => {
  socket.end("HTTP/1.1 400 Bad Request \r\n\r\n")
})

server.listen(8000, () => {
  console.log('ing')
})
